#include <aki/jsbind.h>

struct Person {
    Person() = default;
    Person(std::string name) : name_(name) {}
    std::string name_;
    
    std::string GetName() {
        return name_;
    }
    
    void SetName(std::string name) {
        name_ = name;
    }
};

class TaskRunner {
public:
    TaskRunner() = default;
    int DoTask() {
        AKI_LOG(INFO) << "DoTask";
        return 1;
    }
    Person DoTaskReturnPerson() {
        AKI_LOG(INFO) << "DoTaskReturnPerson";
        return Person("aki");
    }
};

long AsyncTaskReturnLong() { return 0; }

long AsyncTaskLongLongFunctionReturnLong(long handle, long opt, std::function<char *(char *, long, char *)> f) {
    f("x",1,"y");
    return 0;
}

void AsyncTaskReturnVoid() {
    AKI_LOG(INFO) << "AsyncTaskReturnVoid";
}

JSBIND_GLOBAL() {
    JSBIND_PFUNCTION(AsyncTaskReturnLong);
    JSBIND_PFUNCTION(AsyncTaskLongLongFunctionReturnLong);
    JSBIND_PFUNCTION(AsyncTaskReturnVoid);
}

JSBIND_CLASS(Person) {
    JSBIND_CONSTRUCTOR<>();
    JSBIND_FIELD("name", GetName, SetName);
}

JSBIND_CLASS(TaskRunner) {
    JSBIND_CONSTRUCTOR<>();
    JSBIND_PMETHOD(DoTask);
    JSBIND_PMETHOD(DoTaskReturnPerson);
}

JSBIND_ADDON(async_tasks);